<template>
  <main style="padding: 0 5px;overflow: hidden">
    <div class="medical-card row" @click="gotoLink(0)" style="width: 100%">
      <div class="col-lg-3 hidden-xs hospital-info" @click.stop>
        <div class="col-lg-8 ">{{ medicalInfo.paramA }}</div>
        <div class="col-Wlg-4">{{ medicalInfo.paramB }}</div>
      </div>
      <div class="col-lg-9 medical-card-phone">
        <div class="col-lg-5 medical-summary"><span @click.stop>概述：</span>{{ medicalInfo.outline }}</div>
        <div class="col-lg-3 medical-time"><span @click.stop>时间：</span>{{ medicalInfo.time }}</div>
        <div class="col-lg-4 medical-card-phone-button">
          <span><el-button type="text">查看</el-button></span>
          <span><donloadPdf type="text" :medicalId="medicalInfo.id" title="下载"></donloadPdf></span>
          <span v-if="reportAnError"><el-button type="text" @click.stop="reportError">报错</el-button></span>
          <span v-if="revise"><el-button type="text" @click.stop="gotoLink(1)">修改</el-button></span>
        </div>
      </div>
    </div>
  </main>
</template>
<script>
import donloadPdf from "@/components/common/donloadPdf"
export default {
  components: {donloadPdf},
  props: {
    medicalInfo: {
      type: Object,
      default: function (){
        return {
          id: Math.random(),
          paramA: '医院名称',
          paramB: '医生名称',
          outline: '反复上腹泻疼痛2年，加重2天12344632432132',
          time: '2022-10-19',
        }
      }
    }
  },
  methods: {
    reportError() {
      const _this = this
      _this.$prompt('请输入报错信息','提示',{
        confirmButtonText: '确定',
        cancelButtonText: '取消',
      }).then(({value})=>{
        _this.$store.dispatch("userReportError",{id:_this.medicalInfo.id,remark:value})
      })

    },
    gotoLink(edit) {
      const str = this.$route.path.split('/')[1]
      //指定跳转地址
      this.$router.push({name: `/${str}recordInfo`, params: {medicalRecordsId: this.medicalInfo.id,edit:edit}})
    }
  },
  computed: {
    reportAnError() {
      return this.$store.state.identity === 1
    },
    revise() {
      return this.$store.state.identity > 1
    }
  }
}
</script>

